package com.example.administrator.ttphonehelper;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.administrator.ttphonehelper.app.AppActivity;
import com.example.administrator.ttphonehelper.base.BaseActivity;
import com.example.administrator.ttphonehelper.battery.TabHostActivity;
import com.example.administrator.ttphonehelper.camera.CameraActivity;
import com.example.administrator.ttphonehelper.clock.ClockActivity;
import com.example.administrator.ttphonehelper.contact.ContactActivity;
import com.example.administrator.ttphonehelper.process.ProcessActivity;
import com.example.administrator.ttphonehelper.view.CircleMenuLayout;

public class MenuActivity extends BaseActivity {
    private CircleMenuLayout mCircleMenuLayout;

    private static final String[] ITEM_TEXTS = new String[] { "联系人 ", "应用管理", "手机加速",
            "电池管理", "闹钟", "相机" };
    private static final int[] ITEM_IMGS = new int[] { R.mipmap.menu_icon_0_0,
            R.mipmap.menu_icon_1_0, R.mipmap.menu_icon_2_0,
            R.mipmap.menu_icon_3_0, R.mipmap.menu_icon_4_0,
            R.mipmap.menu_icon_5_0 };
    private static final int[] ITEM_ONCLICK_IMGS = new int[] { R.mipmap.menu_icon_0_1,
            R.mipmap.menu_icon_1_1, R.mipmap.menu_icon_2_1,
            R.mipmap.menu_icon_3_1, R.mipmap.menu_icon_4_1,
            R.mipmap.menu_icon_5_1 };
    //菜单中心
    private TextView mTvMenuName;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);

        mCircleMenuLayout = (CircleMenuLayout) findViewById(R.id.id_menulayout);
        mCircleMenuLayout.setMenuItemIconsAndTexts(ITEM_IMGS, ITEM_TEXTS);

        mTvMenuName = (TextView) findViewById(R.id.tv_menu_name);


        mCircleMenuLayout.setOnMenuItemClickListener(new CircleMenuLayout.OnMenuItemClickListener() {
            //pos:点击的是哪个条目
            @Override
            public void itemClick(View view, int pos) {
                //点击菜单改变菜单中心文字
                mTvMenuName.setText(ITEM_TEXTS[pos]);


            }
            //点击菜单中心
            @Override
            public void itemCenterClick(View view) {
            }
            //长按菜单点击事件
            @Override
            public boolean itemLongClick(View view, int pos) {
                switch (pos){
                    //联系人
                    case 0:
                        startActivity(ContactActivity.class);
                        break;
                    //应用管理
                    case 1:
                        startActivity(AppActivity.class);
                        break;
                    //手机加速
                    case 2:
                        startActivity(ProcessActivity.class);
                        break;
                    //电池信息
                    case 3:
                        startActivity(TabHostActivity.class);
                        break;
                    //闹钟
                    case 4:
                        startActivity(ClockActivity.class);
                        break;
                    //相机
                    case 5:
                        startActivity(CameraActivity.class);
                        break;
                }
                return false;
            }
        });
    }
}
